package com.fjrcloud.controller;

import com.fjrcloud.entity.ResponseBean;
import com.fjrcloud.entity.ResponseFactory;
import com.fjrcloud.entity.TemplateWarehouse;
import com.fjrcloud.exception.BusinessException;
import com.fjrcloud.service.TemplateService;
import com.fjrcloud.utils.StatusUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by shengjian.lin on 17-1-4.
 */
@Controller
@RequestMapping("api/template")
public class TemplateController {

    @Autowired
    private TemplateService service;

    @RequestMapping("list")
    @ResponseBody
    public ResponseBean list(Integer pageNum, Integer pageSize){
        return ResponseFactory.getResponseBean(StatusUtils.Success, service.list(pageNum,pageSize));
    }

    @RequestMapping("get")
    @ResponseBody
    public ResponseBean get(Integer id){
        return ResponseFactory.getResponseBean(StatusUtils.Success, service.get(id));
    }

    @RequestMapping("save")
    @ResponseBody
    public ResponseBean save(TemplateWarehouse template,Boolean status,Boolean input) throws BusinessException {
        return ResponseFactory.getResponseBean(StatusUtils.Success, service.save(template));
    }
}
